package com.test.mchelepesa.view_rice;

import com.test.mchelepesa.util_rice.StringUtil_rice;
import com.test.mchelepesa.view_rice.info_input_rice.ContactViewManager_rice;
import com.test.mchelepesa.view_rice.info_input_rice.SelectRelationshipViewManager_rice;
import com.test.mchelepesa.view_rice.info_input_rice.SelectViewManager_rice;

import org.json.JSONException;
import org.json.JSONObject;

public class ContactInputWigets {

    public SelectRelationshipViewManager_rice relationW;
    public ContactViewManager_rice mobileW,nameW;

    public void setMobilenAndName(String mobile,String name){
        if (nameW!=null) nameW.setInput(name);
        if (mobileW!=null) mobileW.setInput(mobile);
    }

    public JSONObject toJson(){

        JSONObject result = new JSONObject();
        try {
            if (relationW!=null) result.put(relationW.getData().getParamName(),relationW.getTextInput());
            if (nameW!=null) result.put(nameW.getData().getParamName(),nameW.getTextInput());
            if (mobileW!=null) result.put(mobileW.getData().getParamName(),mobileW.getTextInput());
        } catch (JSONException e) {
            StringUtil_rice.printException(e);
        }
        return result;

    }

}
